import React, { useEffect, useState } from 'react';
import { Form, Select, } from 'antd';

import ModifyForm from '@/components/Form/modifyForm';
import { formList } from './detailOption';



const Detail = (props: any) => {
    const { initialValues, onCancel, onSubmit, typeList } = props

    //提交信息
    const submit = (value: any) => {
        if (initialValues.id) {
            value.id = initialValues.id
        }
        value.type = {
            label: value.type.label,
            value: value.type.value
        }
        onSubmit(value)
    }

    const cancel = () => {
        onCancel()
    }

    useEffect(() => {
    })

    return (
        <>
            <ModifyForm formList={formList} onSubmit={submit} initialValues={initialValues} onCancel={cancel}>
                {
                    {
                        type: (
                            <Form.Item
                                label='类型'
                                name='type'
                                style={{
                                    height: '50px', marginBottom: '0', width: '100%'
                                }}
                                rules={[{ required: true, message: '请选择类型' }]}
                            >
                                <Select
                                    placeholder={'请选择计划分类'}
                                    options={typeList}
                                    labelInValue={true}
                                    style={{ width: '100%' }}
                                >
                                </Select>
                            </Form.Item>
                        ),
                    }
                }
            </ModifyForm>
        </>
    );
};

export default Detail;